#include "buttonwidget.h"
#include "widgets/ubuttongroup.h"
#include "widgets/umenubutton.h"
#include "widgets/ucalendarwidget.h"
#include "widgets/utagwidget.h"
#include "style/upalette.h"
#include "widgets/udatetimeedit.h"
#include "widgets/udatetimerangeedit.h"
#include "widgets/ucommonbutton.h"
#include "widgets/uedgebutton.h"

#include <QGridLayout>
#include <QStandardItem>
#include <QDateTimeEdit>

ButtonWidget::ButtonWidget(QWidget* parent) : UWidget(parent)
{
    setBackgroundRole(QPalette::Base);
    setRadius(8);
    init();
}

ButtonWidget::~ButtonWidget()
{
}

void ButtonWidget::init()
{
    QGridLayout* layout = new QGridLayout;
    UButtonGroup* group = new UButtonGroup;
    group->setTexts(QStringList() << "qwe" << "rty" << "uio");

    UDateTimeEdit* edit = new UDateTimeEdit(this);
    edit->setMinimumHeight(35);
    edit->setCalendarPopup(true);
    edit->setCalendarWidget(new UCalendarWidget(edit));

    UDatetimeRangeEdit* rangeEdit = new UDatetimeRangeEdit(this);
    rangeEdit->setFixedSize(305, 35);

    UMenuButton* button = new UMenuButton(this);
    button->setFixedSize(120, 30);
    QList<QStandardItem*> list;
    QStandardItem* item = new QStandardItem("123");
    item->setIcon(QIcon::fromTheme("utkwidget"));
    item->appendRow(new QStandardItem("1"));
    item->appendRow(new QStandardItem("2"));
    item->appendRow(new QStandardItem("3"));
    list.append(item);
    QStandardItem* item1 = new QStandardItem("456");
    item->setIcon(QIcon::fromTheme("utkwidget"));
    list.append(item1);
    QStandardItem* item2 = new QStandardItem("789");
    item->setIcon(QIcon::fromTheme("utkwidget"));
    list.append(item2);
    button->addItems(list);

    UCalendarWidget* calendarWidget = new UCalendarWidget(this);

    UEdgeButton *edgeButton = new UEdgeButton(Qt::Horizontal, this);

    UTagWidget* deepTagWidget = new UTagWidget(this);
    deepTagWidget->setButtonFeature(UTagWidgetStyleOption::DeepTag);
    deepTagWidget->setBackgroundRole(UPalette::SuccessBackground);
    deepTagWidget->setEditEnable(true);
    deepTagWidget->setText(tr("DeepTag"));
    deepTagWidget->setMaximumHeight(36);

    UTagWidget* lightTagWidget = new UTagWidget(this);
    lightTagWidget->setButtonFeature(UTagWidgetStyleOption::LightTag);
    lightTagWidget->setBackgroundRole(UPalette::WarningBackground);
    lightTagWidget->setEditEnable(true);
    lightTagWidget->setText(tr("LightTag"));
    lightTagWidget->setMaximumHeight(36);

    UTagWidget* plainTagWidget = new UTagWidget(this);
    plainTagWidget->setButtonFeature(UTagWidgetStyleOption::PlainTag);
    plainTagWidget->setBackgroundRole(UPalette::ErrorBackground);
    plainTagWidget->setEditEnable(true);
    plainTagWidget->setText(tr("PlainTag"));
    plainTagWidget->setMaximumHeight(36);

    UTagWidget* notEditWidget = new UTagWidget(this);
    notEditWidget->setBackgroundRole(UPalette::SuccessBackground);
    notEditWidget->setText(tr("NotEdit"));
    notEditWidget->setMaximumHeight(36);

    UCommonButton* newBuildButton = new UCommonButton("Plain Button", this);
    newBuildButton->setForegroundRole(UPalette::Highlight);
    newBuildButton->setButtonFeature(UCommonButtonOption::UCommandLinkButton);
    newBuildButton->setFixedSize(120, 36);

    layout->addWidget(group, 0, 0);
    layout->addWidget(edit, 0, 1);
    layout->addWidget(button, 0, 2);
    layout->addWidget(calendarWidget, 1, 0);
    layout->addWidget(rangeEdit, 1, 1);
    layout->addWidget(edgeButton, 1, 2);
    layout->addWidget(lightTagWidget, 2, 0);
    layout->addWidget(plainTagWidget, 2, 1);
    layout->addWidget(notEditWidget, 2, 2);
    layout->addWidget(deepTagWidget, 3, 0);
    layout->addWidget(newBuildButton, 3, 1);
    setLayout(layout);
}

